package ioc

import (
	"gitee.com/chicken-c/go-learn/webook/config"
	"github.com/redis/go-redis/v9"
)

func InitRedis() redis.Cmdable {
	type Config struct {
		Addr     string `yaml:"addr"`
		Password string `yaml:"password"`
		DB       int    `yaml:"db"`
	}

	//var c Config
	//err := viper.UnmarshalKey("redis", &c)
	//if err != nil {
	//	panic(err)
	//}

	rCfg := config.Configs.Redis
	cmd := redis.NewClient(&redis.Options{
		Addr:     rCfg.Addr,
		Password: rCfg.Password,
		DB:       rCfg.DB,
	})
	return cmd
}
